package com.chezhujie.www.controller;

import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.io.IOUtils;

public class HttpMain {
	public static void main(String[] args) throws Exception {
//		CommonHttp.send(uri, method, params)
		   HttpClient httpclient = new HttpClient();//方法调用
		String uri="http://localhost:8080/imShejuShare/route/mockClient.action";
		String bodyString="{ \"eventType\": \"11\", \"objects\": [ {  \"mobile\": \"18605818212\",  \"sendid\": \"1490\",  \"result\": \"DELIVRD\",  \"sendTime\": \"2017-06-02 14:40:45\",  \"reportTime\": \"2017-06-06 10:40:30\",  \"spliced\": \"1\" }, {  \"mobile\": \"18605818212\",  \"sendid\": \"1491\",  \"result\": \"DELIVRD\",  \"sendTime\": \"2017-06-02 14:41:00\",  \"reportTime\": \"2017-06-02 10:41:20\",  \"spliced\": \"2\" } ]}";
		 PostMethod post = new PostMethod(uri);//接口地址
		 post.setRequestHeader("Content-Type", "application/json");
		 post.setRequestHeader("CurTime", "1440570500855");
		 post.setRequestHeader("MD5", "feec2cda404d7417b8b427e95748bb56     ");
		 post.setRequestHeader("CheckSum", "001511b8435e0b28044ca50a78e8f983026c5e01	");
		 
		 post.setRequestBody(IOUtils.toInputStream(bodyString, "UTF-8"));
         
         httpclient.executeMethod(post);
         String info = new String(post.getResponseBody(),"UTF-8");
         System.out.println(info);
         /*Map<String,Object> map = JSONObject.parseObject(info, Map.class);*/
//         return map;
	}
}
